package com.hmall.trade.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class MQDelayConfig {
    @Bean
    public DirectExchange DelayDirectExchange(){
        return ExchangeBuilder.directExchange("delay.direct")
                .durable(true)
                .delayed()
                .build();
    }

    @Bean
    public Queue delayQueue(){
        return new Queue("delay.queue",true);
    }

    @Bean
    public Binding delayBinding(Queue delayQueue,DirectExchange DelayDirectExchange){
        return BindingBuilder.bind(delayQueue).to(DelayDirectExchange).with("delay");
    }

}
